package com.ruoyi.analysis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.analysis.domain.OnlineHistoryZlb;
import com.ruoyi.analysis.service.IOnlineHistoryZlbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 制粒二车间分析历史Controller
 * 
 * @author weihanqiang
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/analysis/zlb")
public class OnlineHistoryZlbController extends BaseController
{
    @Autowired
    private IOnlineHistoryZlbService onlineHistoryZlbService;

    /**
     * 查询制粒二车间分析历史列表
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:list')")
    @GetMapping("/list")
    public TableDataInfo list(OnlineHistoryZlb onlineHistoryZlb)
    {
        startPage();
        List<OnlineHistoryZlb> list = onlineHistoryZlbService.selectOnlineHistoryZlbList(onlineHistoryZlb);
        return getDataTable(list);
    }

    /**
     * 导出制粒二车间分析历史列表
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:export')")
    @Log(title = "制粒二车间分析历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OnlineHistoryZlb onlineHistoryZlb)
    {
        List<OnlineHistoryZlb> list = onlineHistoryZlbService.selectOnlineHistoryZlbList(onlineHistoryZlb);
        ExcelUtil<OnlineHistoryZlb> util = new ExcelUtil<OnlineHistoryZlb>(OnlineHistoryZlb.class);
        util.exportExcel(response, list, "制粒二车间分析历史数据");
    }

    /**
     * 获取制粒二车间分析历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:query')")
    @GetMapping(value = "/{onlineResultId}")
    public AjaxResult getInfo(@PathVariable("onlineResultId") Long onlineResultId)
    {
        return success(onlineHistoryZlbService.selectOnlineHistoryZlbByOnlineResultId(onlineResultId));
    }

    /**
     * 新增制粒二车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:add')")
    @Log(title = "制粒二车间分析历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlineHistoryZlb onlineHistoryZlb)
    {
        return toAjax(onlineHistoryZlbService.insertOnlineHistoryZlb(onlineHistoryZlb));
    }

    /**
     * 修改制粒二车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:edit')")
    @Log(title = "制粒二车间分析历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlineHistoryZlb onlineHistoryZlb)
    {
        return toAjax(onlineHistoryZlbService.updateOnlineHistoryZlb(onlineHistoryZlb));
    }

    /**
     * 删除制粒二车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zlb:remove')")
    @Log(title = "制粒二车间分析历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{onlineResultIds}")
    public AjaxResult remove(@PathVariable Long[] onlineResultIds)
    {
        return toAjax(onlineHistoryZlbService.deleteOnlineHistoryZlbByOnlineResultIds(onlineResultIds));
    }
}
